#Alumno: Guastavino Mariano

import math
import unittest

class Resolvente:
    def __init__ (self,a,b,c):
        self.__a=a
        self.__b=b
        self.__c=c

    def prim(self):
        prim=0 - self.__b
        return prim
        
    def seg(self):
        raiz=(self.__b**2) - (4 * self.__a * self.__c)
        if raiz < 0:
            return "No se pueden resolver raices de numeros negativos"
        else:
            seg= math.sqrt(raiz)
            return seg
        
    def ter(self):
        ter=2 * self.__a    
        return ter
        
    def calculo(self):
        if type(self.seg()) == str:
            return self.seg()
            
        else:
            x1=(self.prim() + self.seg())/self.ter()
            x2=(self.prim() - self.seg())/self.ter()
            return x1,x2
        



a = -1
b = 1
c = 0

resolv=Resolvente(a,b,c)
print (resolv.calculo())



class test_Calculo(unittest.TestCase):
    def test (self):
        self.assertEqual(Resolvente(2,6,4).calculo(),(-1,-2))
        self.assertEqual(Resolvente(2,2,4).calculo(),"No se pueden resolver raices de numeros negativos")       

class test_PimerTermino(unittest.TestCase):
    def test (self):
        self.assertEqual(Resolvente(2,6,4).prim(),-6)

class test_SegundoTermino(unittest.TestCase):
    def test (self):
        self.assertEqual(Resolvente(2,2,4).seg(),"No se pueden resolver raices de numeros negativos")
        self.assertEqual(Resolvente(2,4,2).seg(),0)

class test_TercerTermino(unittest.TestCase):
    def test (self):
        self.assertEqual(Resolvente(2,4,2).ter(),4)



if __name__ == "__main__":
    unittest.main()
